package com.dianrui.agent.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dianrui.agent.R;
import com.dianrui.agent.bean.OrderList;
import com.dianrui.agent.bean.Rank;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OrderListAdapter extends BaseQuickAdapter<OrderList,BaseViewHolder> {
   private Context context;

    public OrderListAdapter(int layoutResId, @Nullable List<OrderList> data,Context context) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderList orderData) {
        String showOrderid ="订单编号: "+orderData.order_id;
        String showAccount="会员名称: "+orderData.account;
        String showMobile="手机号码: "+orderData.mobile;
        String carNumbers="车辆编号: "+orderData.number;
        String carDurationTime="使用时长: "+orderData.duration_time;
        String showMoney="费用:￥ "+orderData.money+"元";
        helper.setText(R.id.tv_create_time,orderData.start_time);
        helper.setText(R.id.order_id,showOrderid);
        helper.setText(R.id.tv_account,showAccount);
        helper.setText(R.id.tv_mobile_number,showMobile);
        helper.setText(R.id.tv_number,carNumbers);
        helper.setText(R.id.tv_mobile_duration_time,carDurationTime);
        helper.setText(R.id.money,showMoney);
        //1进行中，2车辆暂停，3未付款，4已完成

        if ("1".equals(orderData.status)) {
            helper.setText(R.id.tv_order_status,"进行中");
            helper.setText(R.id.tv_end_rudning,"远程还车");
            helper.getView(R.id.tv_end_rudning).setVisibility(View.VISIBLE);

        }
        if ("2".equals(orderData.status)) {
            helper.setText(R.id.tv_order_status,"车辆暂停");
            helper.setText(R.id.tv_end_rudning,"远程还车").addOnClickListener(R.id.tv_end_rudning);
            helper.getView(R.id.tv_end_rudning).setVisibility(View.VISIBLE);

        }
        if ("3".equals(orderData.status)) {
            helper.setText(R.id.tv_order_status,"未付款");
            helper.setText(R.id.tv_end_rudning,"确认付款").addOnClickListener(R.id.tv_end_rudning);
            helper.getView(R.id.tv_end_rudning).setVisibility(View.VISIBLE);

        }
        if ("4".equals(orderData.status)) {
            helper.setText(R.id.tv_order_status,"已完成");
            helper.getView(R.id.tv_end_rudning).setVisibility(View.GONE);
        }
    }
}
